﻿using System;

using Microsoft.SharePoint;
using Microsoft.SharePoint.Utilities;

namespace Softlanding.ComponentModel
{
    /// <summary>
    /// Static class containing common helper methods
    /// </summary>
    internal class CommonHelper
    {
        /// <summary>
        /// Retrieves the value for a named resource string from the resource file for the current language
        /// </summary>
        /// <param name="classKey">The base file name of the language resource file containing a localized string value</param>
        /// <param name="resourceKey">The name half of a name/value pair in a resource file</param>
        internal static string GetResourceString(string classKey, string resourceKey)
        {
            try
            {
                return SPUtility.GetLocalizedString(
                    String.Format("$Resources:{0}", resourceKey),
                    classKey,
                    SPContext.Current.Web.Language);
            }
            catch
            {
                return resourceKey;
            }
        }
    }
}